package com.ggs.rg.ybjb.systemmodule.config;


import com.ggs.rg.ybjb.systemmodule.handler.CommonInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * ClassName:CommonConfig
 * Package:com.ggs.rg.ybjb.usermodule.config
 * Description:
 *              自定义拦截器配置类
 * @Date:2021/10/23 20:04
 * @Author:cxw
 */
@Configuration
public class CommonConfig implements WebMvcConfigurer{
    /**
     * 1、编写一个拦截器实现HandlerInterceptor接口
     * 2、拦截器注册到容器中（实现WebMvcConfigurer的addInterceptors）
     * 3、指定拦截规则【如果是拦截所有，静态资源也会被拦截】
     */

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new CommonInterceptor()).addPathPatterns("/**");
        //所有请求都被拦截包括静态资源
        // .excludePathPatterns("/","/login","/css/**","/fonts/**","/images/**","/js/**"); //放行的请求 } }
    }
}
